package com.vrv.vap.res.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.security.Principal;
import java.util.ArrayList;
import java.util.List;

/**
 * @author wh1107066
 */
@Controller
public class HelloWorldRestController {

    private Logger logger = LoggerFactory.getLogger(getClass());


    @PreAuthorize("hasRole('role1')")
    @RequestMapping(value = "/user", method = RequestMethod.GET)
    @ResponseBody
    public List<String> listAllUsers() {
        List<String> list = new ArrayList<>();
        list.add("aaaa");
        return list;
    }

    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    @ResponseBody
    public String hello() {
        logger.info("-------------方法体-------------");
        return "hello";
    }

    @GetMapping("/getCurUser")
    public Principal user(Principal user) {
        return user;
    }


}